const qr = require('qr-image');

class QrCodeController {
	getQrCode(req, res, next) {
		var text = req.query.text;
		try {
			var img = qr.image(text, { size: 10 });
			res.writeHead(200, { 'Content-Type': 'image/png' });
			img.pipe(res);
		} catch (e) {
			res.writeHead(414, { 'Content-Type': 'text/html' });
			res.end('<h1>414 Request-URI Too Large</h1>');
		}
	}
}

module.exports = new QrCodeController();
